package com.git.dengchongshuang.managementsystem.menu;

import java.util.Scanner;

// 菜单测试程序
public class MenuTest {
    public static void main(String[] args) {
        Menu startMenu = new Menu(60);

        initStartMenu(startMenu);

        while (true) {
            try {
                startMenu.showMenu();
                startMenu.userInput("请输入选项: ");
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }

        }

    }

    public static void initStartMenu(Menu startMenu) {
        startMenu.addMenuTitle("通讯录管理系统(20240514-2149)  主菜单(测试用)");

        startMenu.addMenuItem(new MenuItem("获取所有联系人", () -> {
            // 这里写选择选项后需要进行的操作
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入密码");
            int n = scanner.nextInt();
            System.out.println(n);
        }), "0");
        startMenu.addMenuItem(new MenuItem("获取所有联系人(按时间排序)", () -> {
            System.out.println("选项1");

        }), "1");
        startMenu.addMenuItem(new MenuItem("获取所有联系人(按姓名排序)", () -> {
            System.out.println("选项2");

        }), "2");
        startMenu.addMenuItem(new MenuItem("获取所有联系人(按电话号码排序)", () -> {
            System.out.println("选项3");

        }), "3");

        startMenu.addMenuItem(new MenuItem("添加联系人", () -> {
            System.out.println("选项4");
        }), "4");
        startMenu.addMenuItem(new MenuItem("修改联系人", () -> {
            System.out.println("选项5");
        }), "5");
        startMenu.addMenuItem(new MenuItem("删除联系人", () -> {
            System.out.println("选项6");
        }), "6");

        startMenu.addMenuItem("测试", "c", () -> {
            System.out.println("测试方法6");
        });
        startMenu.addMenuItem(new MenuItem("退出程序", () -> {
            System.out.println("~拜拜~");
            System.exit(0);

        }), "q");
    }
}
